﻿import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Admin
 * Date: 2022-12-11
 * Time: 17:06
 */
public class Demo1 {
   public static void main(String[] args) {
        String str1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        String str2 = "22233344455566677778889999";
        HashMap<Character,Character> map = new HashMap<>();
        
        for(int i = 0; i < str1.length(); i++) {
            map.put(str1.charAt(i),str2.charAt(i));
        }
        
        Scanner scan = new Scanner(System.in);
        
        while(scan.hasNext()) {
            
            int n = scan.nextInt();
            Set<String> set = new TreeSet<>();
            
            for(int i = 0; i < n; i++) {
                String input = scan.next();
                char[] arr = input.toCharArray();
                StringBuffer buff = new StringBuffer();
                
                for(char ch : arr) {
                    if(ch >= '0' && ch <= '9') {
                        buff.append(ch);
                    }else if (ch >= 'A' && ch <= 'Z' ){
                        buff.append(map.get(ch));
                    }
                }
                
                String line = buff.substring(0,3) + '-' + buff.substring(3);
                
                set.add(line);
            }
            
            for(String str : set) {
                System.out.println(str);
            }
            System.out.println();
        }
    } 
}
